﻿@model MiniShoppingCartModel
@using Nop.Web.Models.ShoppingCart;
<div id="flyout-cart" class="flyout-cart">
    <div class="mini-shopping-cart">
        <div class="count">
            @if (Model.TotalProducts == 0)
            {
                @T("ShoppingCart.Mini.NoItems")
            }
            else
            {
                @Html.Raw(string.Format(T("ShoppingCart.Mini.ItemsText").Text, string.Format("<a href=\"{0}\" class=\"items\">{1}</a>", Url.RouteUrl("ShoppingCart"), string.Format(T("ShoppingCart.Mini.Items").Text, Model.TotalProducts))))
            }
        </div>
        @if (Model.TotalProducts > 0)
        {
            if (Model.Items.Count > 0)
            {
            <div class="items">
                <table>
                    <colgroup>
                        @if (Model.ShowProductImages)
                        {
                            <col width="1" />
                        }
                        <col />
                    </colgroup>
                    <tbody>
                        @for (int i = 0; i < Model.Items.Count; i++)
                        {
                            var item = Model.Items[i];
                            <tr class="item @(i == 0 ? "first" : null)">
                                @if (Model.ShowProductImages)
                                {
                                    <td class="picture">
                                        <a href="@Url.RouteUrl("Product", new { SeName = item.ProductSeName })" title="@item.Picture.Title">
                                            <img alt="@item.Picture.AlternateText" src="@item.Picture.ImageUrl" title="@item.Picture.Title" />
                                        </a>
                                    </td>
                                }
                                <td class="product">
                                    <div class="name">
                                        <a href="@Url.RouteUrl("Product", new { SeName = item.ProductSeName })">@item.ProductName</a>
                                    </div>
                                    @if (!String.IsNullOrEmpty(item.AttributeInfo))
                                    {
                                        <div class="attributes">
                                            @Html.Raw(item.AttributeInfo)
                                        </div>
                                    }
                                    <div class="price">@T("ShoppingCart.Mini.UnitPrice"): <span>@item.UnitPrice</span></div>
                                    <div class="quantity">@T("ShoppingCart.Mini.Quantity"): <span>@item.Quantity</span></div>
                                </td>
                            </tr>
                        }
                    </tbody>
                </table>
            </div>
            <div class="clear">
            </div>
            }
            <div class="totals">@T("ShoppingCart.Totals.SubTotal"): <strong>@Model.SubTotal</strong></div>
            <div class="clear">
            </div>
            <div class="buttons">
                @if (Model.DisplayShoppingCartButton)
                {
                    <input type="button" value="@T("ShoppingCart.Mini.ViewCart")" class="button-1 cart-button" onclick="setLocation('@(Url.RouteUrl("ShoppingCart"))')" />
                    
                }
                @if (Model.DisplayCheckoutButton)
                {
                    var checkoutUrl = "";
                    if (Model.AnonymousCheckoutAllowed && Model.CurrentCustomerIsGuest)
                    {
                        checkoutUrl = Url.RouteUrl("LoginCheckoutAsGuest", new { returnUrl = Url.RouteUrl("ShoppingCart") });
                    }
                    else
                    {
                        checkoutUrl = Url.RouteUrl("Checkout");
                    }
                    <input type="button" value="@T("Checkout.Button")" class="button-1 checkout-button" onclick="setLocation('@checkoutUrl')" />
                }
            </div>
        }
    </div>
</div>
